import { createApp } from 'vue';
import pinia from '/@/stores/index';
import App from './App.vue';
import router from './router';
import { directive } from '/@/directive';
import { i18n } from '/@/i18n';
import other from '/@/utils/other';
import log from '/@/utils/prettyLog';
import './styles/element.scss';
import ElementPlus from 'element-plus';
import '/@/theme/tailwind.css';
import 'element-plus/dist/index.css';
import '/@/theme/index.scss';
import mitt from 'mitt';

const emitter = mitt();

import {
	ElementIcons,
	Pagination,
	RightToolbar,
	DictTag,
	UploadExcel,
	uploadOne,
	UploadFile,
	UploadImg,
	Editor,
	ComPop,
	Tip,
	DelWrap,
	BasicContainer,
	BasicTable,
	BasicTableFrom,
	DetailsContainer,
	DetailsContainerTitle,
	ElectronicFence,
	InputMap,
	TriangleBox,
	BasicCell,
	AzureBox,
	WithFixedPageContainer,
} from '/@/components/index';
import {
	parseTime,
	parseDate,
	dateTimeStr,
	dateStr,
	timeStr,
} from '/@/utils/formatTime';

// 布局工具
import { Splitpanes, Pane } from 'splitpanes';
import 'splitpanes/dist/splitpanes.css';

const app = createApp(App);

//挂到全局
app.config.globalProperties.emitter = emitter;

// 导入通用自定义组件
app.component('DictTag', DictTag);
app.component('Pagination', Pagination);
app.component('RightToolbar', RightToolbar);
app.component('uploadExcel', UploadExcel);
app.component('uploadOne', uploadOne);

app.component('UploadFile', UploadFile);
app.component('UploadImg', UploadImg);
app.component('Editor', Editor);
app.component('ComPop', ComPop);
app.component('Tip', Tip);
app.component('DelWrap', DelWrap);

app.component('BasicContainer', BasicContainer);
app.component('BasicTable', BasicTable);
app.component('BasicTableFrom', BasicTableFrom);
app.component('DetailsContainer', DetailsContainer);
app.component('DetailsContainerTitle', DetailsContainerTitle);
app.component('ElectronicFence', ElectronicFence);
app.component('InputMap', InputMap);
app.component('TriangleBox', TriangleBox);
app.component('BasicCell', BasicCell);
app.component('AzureBox', AzureBox);
app.component('WithFixedPageContainer', WithFixedPageContainer);
// 导入布局插件
app.component('Splitpanes', Splitpanes);
app.component('Pane', Pane);
// 全局方法挂载
app.config.globalProperties.parseTime = parseTime;
app.config.globalProperties.parseDate = parseDate;
app.config.globalProperties.dateTimeStr = dateTimeStr;
app.config.globalProperties.dateStr = dateStr;
app.config.globalProperties.timeStr = timeStr;
app.config.globalProperties.$log = log;
app.config.globalProperties.baseURL = import.meta.env.VITE_API_URL;

import Viewer from 'v-viewer';
import 'viewerjs/dist/viewer.css';
//可以指定一些默认配置
app.use(Viewer, {
	Options: {
		inline: true,
		button: true, //右上角按钮
		navbar: true, //底部缩略图
		title: true, //当前图片标题
		toolbar: true, //底部工具栏
		tooltip: true, //显示缩放百分比
		movable: true, //是否可以移动
		zoomable: true, //是否可以缩放
		rotatable: true, //是否可旋转
		scalable: true, //是否可翻转
		transition: true, //使用 CSS3 过度
		fullscreen: true, //播放时是否全屏
		keyboard: true, //是否支持键盘
		url: 'data-source',
		zIndex: 9999,
	},
	defaultOptions: {
		zIndex: 9999, //解决图片放大的层级问题
	},
});

directive(app);
other.elSvg(app);

app
	.use(pinia) // pinia 存储
	.use(router) // 路由
	.use(ElementPlus) // ElementPlus 全局引入
	.use(ElementIcons) // elementIcons 图标全局引入
	.use(i18n) // 国际化
	.mount('#app');
